package com.boboPlanet.comm.entity.dto;

import com.alibaba.fastjson.JSON;
import com.boboPlanet.comm.entity.po.LoginUserInfoPO;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;

import java.io.Serializable;

/**
 * @Description: TODO 星球 MQ 消息体
 * @Author: mis_wu
 * @Date: 2023/6/22
 * @Company planet
 **/
@Data
public class PlanetMqMsg implements Serializable {

    private String queue;

    private String exchange;

    private String routingKey;

    private String messageId;

    private LoginUserInfoPO loginUserInfo;

    private Object data;

    private String gray;

    public String serialize() {
        String jsonString;
        ObjectMapper mapper = new ObjectMapper();

        try {
            jsonString = mapper.writeValueAsString(this);
            return jsonString;
        } catch (JsonProcessingException var4) {
            throw new RuntimeException(var4);
        }
    }

    public static PlanetMqMsg deserialize(String data) {
        return JSON.parseObject(data, PlanetMqMsg.class);
    }



}
